package com.dongdongshop.service.impl;

import com.dongdongshop.domain.model.TbProvinces;
import com.dongdongshop.domain.vo.ProvincesVO;
import com.dongdongshop.mapper.TbProvincesMapper;
import com.dongdongshop.service.ProvincesService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class ProvincesServiceImpl implements ProvincesService {

    @Autowired
    private TbProvincesMapper provincesMapper;

    @Override
    public List<ProvincesVO> getProvinces() {
        List<TbProvinces> tbProvincesList = provincesMapper.selectByExample(null);
        return tbProvincesList.stream().map(tbProvinces -> {
            ProvincesVO vo = new ProvincesVO();
            BeanUtils.copyProperties(tbProvinces,vo);
            return vo;
        }).collect(Collectors.toList());
    }
}
